<?php
switch($_POST["cmd"]) {
case "bf":
	// add new task
	$data = "cmd=task_add\n";
	$network->send($data);
	while($from = $network->recv()) {
		if(strpos($from, "task_add_reply") !== false) {
			break;
		}
	}
	$pm->init($from, "|");
	$task_id = $pm->get("id");

	if(!strcmp($_POST["detail"], "bf_gen")) {
		$length = 4;
//		$chars = "abcdefghijklmnopqrstuvwxyz";
		$chars = "abcdefghijklmnopqrstuvwxyz"
				."ABCDEFGHIJKLMNOPQRSTUVWXYZ"
				."0123456789";

//				."~`!@#$%^&*()_-+=[]{}\|;':\".,<>/?";

		$network->send("cmd=task_set|id=$task_id|data=todo_count|value=1\n");
		$network->send("cmd=task_set|id=$task_id|data=block_size|value=10000\n");
		$network->send("cmd=task_set|id=$task_id|data=timeout|value=30\n");

		$network->send("cmd=task_set|id=$task_id|data=db_host|value="
				. $settings["default"]["db_host"] ."\n");
		$network->send("cmd=task_set|id=$task_id|data=db_port|value="
				. $settings["default"]["db_port"] ."\n");
		$network->send("cmd=task_set|id=$task_id|data=db_name|value="
				. $settings["default"]["db_name"] ."\n");
		$network->send("cmd=task_set|id=$task_id|data=db_user|value="
				. $settings["default"]["db_user"] ."\n");
		$network->send("cmd=task_set|id=$task_id|data=db_pass|value="
				. $settings["default"]["db_pass"] ."\n");

		$network->send("cmd=task_set|id=$task_id|data=todo|value=bf_gen\n");
		$network->send("cmd=task_set|id=$task_id|data=chars|value=$chars\n");
		$network->send("cmd=task_set|id=$task_id|data=length|value=$length\n");

		$network->send("cmd=task_start|id=$task_id\n");
	}
	break;
}
?>
